<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"www.lixiaofei.cn","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":true,"storage":true,"lazyload":true,"nav":{"valine":{"order":-1}}},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="还记得上次写的如何给小孩约马术课的事情吗？见这里 Python 约课， 本想一劳永逸，但是好景不长，预约系统升级了，而且还换了服务商，从之前的公众号 H5 应用，换成了小程序，之前编写的方式直接失效，孩子又没马骑了 谁叫他遇到一个程序员老爸呢？这点事儿难不倒我，开干">
<meta property="og:type" content="article">
<meta property="og:title" content="不会爬小程序，叫什么会爬虫">
<meta property="og:url" content="http://www.lixiaofei.cn/2021-04-30-horse2/index.html">
<meta property="og:site_name" content="管窥程序">
<meta property="og:description" content="还记得上次写的如何给小孩约马术课的事情吗？见这里 Python 约课， 本想一劳永逸，但是好景不长，预约系统升级了，而且还换了服务商，从之前的公众号 H5 应用，换成了小程序，之前编写的方式直接失效，孩子又没马骑了 谁叫他遇到一个程序员老爸呢？这点事儿难不倒我，开干">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://www.lixiaofei.cn/images/2021/05/house2/01.jpg">
<meta property="og:image" content="http://www.lixiaofei.cn/images/2021/05/house2/06.gif">
<meta property="og:image" content="http://www.lixiaofei.cn/images/2021/05/house2/02.jpg">
<meta property="og:image" content="http://www.lixiaofei.cn/images/2021/05/house2/03.jpg">
<meta property="og:image" content="http://www.lixiaofei.cn/images/2021/05/house2/04.jpg">
<meta property="og:image" content="http://www.lixiaofei.cn/images/2021/05/house2/05.jpg">
<meta property="article:published_time" content="2021-04-30T05:17:02.271Z">
<meta property="article:modified_time" content="2021-05-10T06:12:16.100Z">
<meta property="article:author" content="太阳雪">
<meta property="article:tag" content="编程">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://www.lixiaofei.cn/images/2021/05/house2/01.jpg">

<link rel="canonical" href="http://www.lixiaofei.cn/2021-04-30-horse2/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>不会爬小程序，叫什么会爬虫 | 管窥程序</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">管窥程序</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Today is a gift</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

  <a href="https://github.com/alisx" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://www.lixiaofei.cn/2021-04-30-horse2/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="太阳雪">
      <meta itemprop="description" content="总结 技术 思考 想法">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="管窥程序">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          不会爬小程序，叫什么会爬虫
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-04-30 13:17:02" itemprop="dateCreated datePublished" datetime="2021-04-30T13:17:02+08:00">2021-04-30</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-05-10 14:12:16" itemprop="dateModified" datetime="2021-05-10T14:12:16+08:00">2021-05-10</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/python/" itemprop="url" rel="index"><span itemprop="name">python</span></a>
                </span>
            </span>

          
            <span id="/2021-04-30-horse2/" class="post-meta-item leancloud_visitors" data-flag-title="不会爬小程序，叫什么会爬虫" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021-04-30-horse2/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021-04-30-horse2/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>还记得上次写的如何给小孩约马术课的事情吗？见这里 <a href="https://mp.weixin.qq.com/s/XqICwC9_cRBhua-6-lbjWw" target="_blank" rel="noopener" title="Python 约课">Python 约课</a>， 本想一劳永逸，但是好景不长，预约系统升级了，而且还换了服务商，从之前的公众号 H5 应用，换成了小程序，之前编写的方式直接失效，孩子又没马骑了</p>
<p>谁叫他遇到一个程序员老爸呢？这点事儿难不倒我，开干</p>
<a id="more"></a>
<h2 id="小程序的不同之处">小程序的不同之处</h2>
<p>与访问 H5 不同的是，小程序相当于一个 app，其上的操作是经过微信的封装的，所以无法直接获取到请求链接和数据，同样也无法获得返回的数据</p>
<p>就像一个 app，他的请求都是内置在程序内的</p>
<p>对于这种情况，就需要使用抓包工具，比如 Charles</p>
<p>它的原理是，作为请求的代理，即小程序 或 app 发送请求时，先将请求发送给代理，然后再由代理将请求发送给服务器，返回的过程也一样</p>
<p>这也是著名的 <code>中间人攻击</code></p>
<p><img src="../images/2021/05/house2/01.jpg" alt="中间人攻击"></p>
<p>如果要获取 小程序或者 app 的具体请求，就需要用这种方式，让代理获取请求和相应的数据</p>
<p>具体这么玩呢？直接参考 Charles 教程或者在网上一搜，就知道了，这里推荐一篇<a href="https://www.jianshu.com/p/8385a13b0e5c" target="_blank" rel="noopener" title="Android抓包">Android抓包-Charles</a>，供各位参考</p>
<h2 id="飞越-Https-协议">飞越 Https 协议</h2>
<p>如果配置好了之后，可能发现 Charles 抓的包全是乱码，这是因为 小程序必须使用 Https 协议</p>
<p>也就是在 Http 协助之上对请求数据做一次加密，以防止中间人攻击</p>
<p>Https 的原理也很简单，就是目标网址申请一个 https 证书，然后将其对称密钥的公钥发布在颁发证书的网站上</p>
<p>当由请求访问目标服务器时，目标服务器会要求其进行加满请求，这是客户端程序会自动去证书颁发网址下载目标网站的公钥，也就是证书</p>
<p>然后对请求的数据用公钥加密，再发送到目标服务器上，目标服务器收到请求后，会用自己的私钥解密请求数据，转化为明文继续处理</p>
<p>当返回响应时也时一样的，不过目标服务器用自己的私钥加密，客户端用公钥解密</p>
<p>详细说明可参考 <a href="https://book.douban.com/subject/25863515/" target="_blank" rel="noopener" title="图解HTTP">图解HTTP</a></p>
<p>这里只需要按照 Charles 的说明，再手机端按照 Charles 颁发的证书就可以了</p>
<p>不过如果用的是 Android 系统的话，需要注意 Android 7.0 之后 谷歌升级了安全策略，不再支持用户自主安装的证书</p>
<p>有两个解决办法：</p>
<ol>
<li>对手机做root，然后修改手机的安全策略，详细可参考: <a href="https://bbs.huaweicloud.com/blogs/245014" target="_blank" rel="noopener" title="Android 7.0 安装证书">通过Charles抓取Android的Https链接数据</a></li>
<li>找一个未升级到 Android 7.0 的手机</li>
</ol>
<p>翻出了一台几年前的手机，充电，开机，查看版本，是 Android 6，哈哈，太幸运了<br>
<img src="../images/2021/05/house2/06.gif" alt=""></p>
<p>安装好证书后，在次抓包，就可以看见请求的数据了</p>
<p><img src="../images/2021/05/house2/02.jpg" alt="Charles 抓包"></p>
<h2 id="轻车熟路">轻车熟路</h2>
<p>得到了请求链接和请求数据，就可以像上一次一样编写成 Python 脚本了</p>
<p>上一次是通过浏览器中请求的方式获取的请求数据，在 Charles 中，获取也很方便，如下图</p>
<p><img src="../images/2021/05/house2/03.jpg" alt="Charles 获取请求"></p>
<p>通过快捷菜单，获取 curl 命令的请求数据，然后复制到 网站 <a href="https://curl.trillworks.com/" target="_blank" rel="noopener" title="Curl 转化为 Python 请求">https://curl.trillworks.com/</a></p>
<p><img src="../images/2021/05/house2/04.jpg" alt="Charles 获取请求"></p>
<p>然后将 python 代码拷出到文件里，执行即可，够简单吧，具体可以参考之前的文章: <a href="https://mp.weixin.qq.com/s/XqICwC9_cRBhua-6-lbjWw" target="_blank" rel="noopener" title="这才是使用Python的正确姿势！">这才是使用Python的正确姿势！</a> 的文章描述</p>
<h2 id="更进一步">更进一步</h2>
<p>这里还需要解决一个问题，可能是我这个做老爸的实在太懒了</p>
<p>因为正直五一假期，假期结束后的一个周六是工作日，而之前的程序会预约每周六的课程，如果是工作日的话，刚好冲突了</p>
<p>所以需要避开工作日，那么首先想到的是有没有判断节假日的库可用，找了一圈，发现有些 api 可以，但是不是需要付费就是需要注册，比较麻烦，于是直接去万年历中去抓取</p>
<p>锁定的一个万能历网站 <a href="https://wannianrili.bmcx.com" target="_blank" rel="noopener">https://wannianrili.bmcx.com</a>，标记清晰，数据准确，而且免费</p>
<p><img src="../images/2021/05/house2/05.jpg" alt="万年历"></p>
<p>分析请求，是通过链接 <a href="https://wannianrili.bmcx.com/ajax/" target="_blank" rel="noopener">https://wannianrili.bmcx.com/ajax/</a> 获取一个月的数据，获取的结果是 xml 格式的数据</p>
<p>分析发现，日期类型是通过 css 的类来标记的，分别是 <code>wnrl_riqi_ban</code>，<code>wnrl_riqi_mo</code>，<code>wnrl_riqi_xiu</code>，表示 上班，周末 和 休息</p>
<p>所以只需要对获取的 xml 进行解析就好了</p>
<p>这里我又再进一步 —— 因为获取的是一个月的，每次请求获取又点费，而且是在抢预约，所以需要更高的效率（哈哈，实际上是想炫炫技而已），于是做了一个小缓存，每次看看有没有当月的 xml 文件，如果有直接读取，没有则获取，并存储起来</p>
<p>实现了节假日判断后，在主预约程序里加一个判断，如果要预约的日子是工作日，再后延一日，继续判断，直到遇到一个费工作日</p>
<p>这里展示一下判断日期类型的代码：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> requests</span><br><span class="line"><span class="keyword">from</span> lxml <span class="keyword">import</span> etree</span><br><span class="line"><span class="keyword">import</span> datetime</span><br><span class="line"><span class="keyword">import</span> os</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">getDaysInfo</span><span class="params">(ym)</span>:</span></span><br><span class="line">    cacheName = ym + <span class="string">".html"</span></span><br><span class="line">    <span class="keyword">if</span> os.path.exists(cacheName):</span><br><span class="line">        content = open(cacheName).read()</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        content = requestsDayInfo(ym)</span><br><span class="line">        saveFile(cacheName, content)</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">return</span> content</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">requestsDayInfo</span><span class="params">(ym=None)</span>:</span></span><br><span class="line">    headers = &#123;</span><br><span class="line">        <span class="string">'sec-ch-ua'</span>: <span class="string">'"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"'</span>,</span><br><span class="line">        <span class="string">'Referer'</span>: <span class="string">'https://wannianrili.bmcx.com/'</span>,</span><br><span class="line">        <span class="string">'sec-ch-ua-mobile'</span>: <span class="string">'?0'</span>,</span><br><span class="line">        <span class="string">'User-Agent'</span>: <span class="string">'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36'</span>,</span><br><span class="line">    &#125;</span><br><span class="line">    params = (</span><br><span class="line">        (<span class="string">'q'</span>, ym),</span><br><span class="line">        (<span class="string">'v'</span>, <span class="string">'20031912'</span>),</span><br><span class="line">    )</span><br><span class="line">    response = requests.get(<span class="string">'https://wannianrili.bmcx.com/ajax/'</span>, headers=headers, params=params)</span><br><span class="line">    <span class="keyword">return</span> response.text</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">saveFile</span><span class="params">(name, content)</span>:</span></span><br><span class="line">    print(name)</span><br><span class="line">    f = open(name,<span class="string">'w'</span>)</span><br><span class="line">    f.write(content)</span><br><span class="line">    f.close()</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">parse</span><span class="params">(content, d)</span>:</span></span><br><span class="line">    html = etree.HTML(content)</span><br><span class="line">    dayclass = html.xpath(<span class="string">'//*[@id="wnrl_riqi_id_'</span>+str(int(d)<span class="number">-1</span>)+<span class="string">'"]'</span>)[<span class="number">0</span>].attrib.get(<span class="string">'class'</span>)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> dayclass <span class="keyword">is</span> <span class="literal">None</span> <span class="keyword">or</span> dayclass == <span class="string">'wnrl_riqi_ban'</span>:</span><br><span class="line">        <span class="keyword">return</span> <span class="number">1</span></span><br><span class="line">    <span class="keyword">elif</span> dayclass == <span class="string">'wnrl_riqi_mo'</span>:</span><br><span class="line">        <span class="keyword">return</span> <span class="number">2</span></span><br><span class="line">    <span class="keyword">elif</span> dayclass == <span class="string">'wnrl_riqi_xiu'</span>:</span><br><span class="line">        <span class="keyword">return</span> <span class="number">3</span></span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        <span class="keyword">return</span> <span class="number">0</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">getDayType</span><span class="params">(date)</span>:</span></span><br><span class="line">    str_date = date.strftime(<span class="string">'%Y-%m-%d'</span>)</span><br><span class="line">    ymd = str_date.split(<span class="string">"-"</span>)</span><br><span class="line">    ym = ymd[<span class="number">0</span>] + <span class="string">'-'</span> + ymd[<span class="number">1</span>]</span><br><span class="line">    d = ymd[<span class="number">2</span>]</span><br><span class="line">    <span class="keyword">return</span> parse(getDaysInfo(ym), d)</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">"__main__"</span>:</span><br><span class="line">    delta = <span class="number">1</span>  <span class="comment"># 探索步长为一日</span></span><br><span class="line">    date = datetime.date.today()</span><br><span class="line">    <span class="keyword">while</span>(getDayType(date)&lt;<span class="number">2</span>):</span><br><span class="line">        delta += <span class="number">1</span></span><br><span class="line">        date = datetime.date.today() + datetime.timedelta(days=delta)</span><br></pre></td></tr></table></figure>
<h2 id="总结">总结</h2>
<p>好了，现在又可以做优雅的老爸了哈哈，对孩子最好的教育就是陪孩子一起成长，无论是什么方面，如果你恰巧喜欢编程，会编程的话，可以尝试和孩子一起做些又意思的东西，比如 <a href="https://mp.weixin.qq.com/s/czcGKk6RTrZVi6-KRUAR0w" target="_blank" rel="noopener" title="做个掷骰子游戏">做个掷骰子游戏</a></p>
<p>笔芯</p>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E7%BC%96%E7%A8%8B/" rel="tag"># 编程</a>
          </div>

        

			<div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center">
    <img id="wechat_subscriber_qcode" src="/images/wechat-qcode.png" alt="太阳雪 wechat" style="width: 200px; max-width: 100%;"/>
    <div>关注我，获得更多精彩内容</div>
</div>

        
		
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021-04-09-facecode/" rel="prev" title="别以为，有了人脸识别就万事无忧了">
      <i class="fa fa-chevron-left"></i> 别以为，有了人脸识别就万事无忧了
    </a></div>
      <div class="post-nav-item">
    <a href="/2021-05-10-licenses/" rel="next" title="优秀的程序员，必须知道的">
      优秀的程序员，必须知道的 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#小程序的不同之处"><span class="nav-number">1.</span> <span class="nav-text">小程序的不同之处</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#飞越-Https-协议"><span class="nav-number">2.</span> <span class="nav-text">飞越 Https 协议</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#轻车熟路"><span class="nav-number">3.</span> <span class="nav-text">轻车熟路</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#更进一步"><span class="nav-number">4.</span> <span class="nav-text">更进一步</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#总结"><span class="nav-number">5.</span> <span class="nav-text">总结</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="太阳雪"
      src="/images/avatar.png">
  <p class="site-author-name" itemprop="name">太阳雪</p>
  <div class="site-description" itemprop="description">总结 技术 思考 想法</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">88</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">47</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">太阳雪</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://mist.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Mist</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  
  <script>
    (function(){
      var canonicalURL, curProtocol;
      //Get the <link> tag
      var x=document.getElementsByTagName("link");
		//Find the last canonical URL
		if(x.length > 0){
			for (i=0;i<x.length;i++){
				if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
					canonicalURL=x[i].href;
				}
			}
		}
    //Get protocol
	    if (!canonicalURL){
	    	curProtocol = window.location.protocol.split(':')[0];
	    }
	    else{
	    	curProtocol = canonicalURL.split(':')[0];
	    }
      //Get current URL if the canonical URL does not exist
	    if (!canonicalURL) canonicalURL = window.location.href;
	    //Assign script content. Replace current URL with the canonical URL
      !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
  </script>















  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'teRj7yeJj0xpfGKLJ5uFdbIu-gzGzoHsz',
      appKey     : '3uie0p1nxouCCnkjiXTEBeLd',
      placeholder: "您的关注是我的动力",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-cn' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
